<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.lavegue.model.Area" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户管理-->>用户列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<script type='text/javascript' src='dwr/interface/userdwr.js'></script>
     <script type='text/javascript' src='dwr/interface/areadwr.js'></script>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type='text/javascript' src='js/jquery.validate.min.js'></script>
 	<script type='text/javascript' src='js/common.js'></script>
	<meta http-equiv="pragma" content="no-cache" />
	 <script type='text/javascript' src='<%=basePath %>/dwr/engine.js'></script>
	 <script type='text/javascript' src='<%=basePath %>/dwr/util.js'></script>
	<link href="images/css.css"  rel="stylesheet" type="text/css" />
<link href="backStageManage/bs.css"  rel="stylesheet" type="text/css" />
	<script language="javascript" type="text/javascript" src="<%=basePath %>/date/WdatePicker.js"></script>

<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.STYLE14 {color: #F58000}
.STYLE15 {color: #F18910}
.STYLE16 {color: #F75200}


-->
</style>

<script type="text/javascript">
	function checkVal(){
		var beginTime= $.trim($("#beginTime").val());
		var endTime= $.trim($("#endTime").val());
		var account = $.trim($("#account").val());   //手机号
		var balance = $.trim($("#balance").val());  //账户余额
		var userName = $.trim($("#userName").val()); //真实姓名 
		//所在地区的值
		var province = $.trim($("#province").val()); //获取省份值
		var city = $.trim($("#city").val()); //获取市区值
		var area = $.trim($("#area").val()); //获取区域值
		
		
		if(beginTime !="" && endTime !=""){
			if(beginTime > endTime){
				$("#errorSpan").html("&nbsp;&nbsp;选择的开始时间不能大于结束时间.");
				return false;
			}else{
				$("#errorSpan").html("");
			}
		}else{
				$("#errorSpan").html("");
			}
		if(userName !="" && userName.length > 0){
			   		//----以下是效验真实姓名是否是中文
			if(isIllegalChar(userName)){
					$("#errorSpan").html("&nbsp;&nbsp;姓名包含了非法字符.");
					$("#userName").select();
					return false;
			}
		}else{
			$("#errorSpan").html("");
		}
			//----以下是效验手机号码
			if(account != ""){
				if(!isValidMobile(account)){
				$("#errorSpan").html("&nbsp;&nbsp;输入的手机号码有误.");
				$("#account").select();
				return false;
				}else{
					$("#errorSpan").html("");
				}
			}else{
				$("#errorSpan").html("");
			}
			
			
			 //------------以下是效验用户金额的正确性
			 if(balance != ""){
			 	if(!isCurrency(balance)){
					$("#errorSpan").html("&nbsp;&nbsp;输入的账户余额有误.");
					$("#balance").select();
					return false;
				}else{
					$("#errorSpan").html("");
				}
			 }else{
				$("#errorSpan").html("");
			 }
			
		if(province != 0){ //省份
			//	$("#errorSpan").html("请选择所在地区.");
			$("#errorSpan").html("");
			$("#userProvince").val(province);
		}else{
			$("#errorSpan").html("");
		}
		if(city!=0){ //城市
			$("#errorSpan").html("");
			$("#userCity").val(city);
		}	
		if(area!=0){ //区县
			$("#errorSpan").html("");
			$("#userZone").val(area);
		}
			var  pp = $.trim($("#userProvince").val());
			var  City = $.trim($("#userCity").val());
			//	alert("Province="+pp+",city="+City);	
		return true;
	}

function serachInfoSubmit(){
	if(!checkVal()){
		return false;
	}else{
		document.cxFrm.submit();
	}
}

	//转至多少页码
	 function changePage(listId)
	 {
	 	//alert(listId);
	  document.location.href="bsumAction!toDisplayAllUserList.action?pageNo="+listId;
	 } 
	 
/**请求到展示用户充值记录的详情页面
 *  传一个页数和用户ID过去
 */
function userRechargeRecordDetail(pageNo,userId){
	alert("pageNo="+pageNo+", userId="+userId);
	document.location.href="bsumAction!doShowUserRechargeDetail.action?pageNo="+pageNo+"userId="+userId;
}

function isIllegalChar(str) {
	var voidChar = /[@#\$%\^&\*\+\?:|.!~=>`<]+/g;
	return voidChar.test(str);
}
function isCurrency(currency){
 	var curr = /^\d+(\.\d+)?$/;
 	return curr.test(currency);
}
/**
 * 判断是不是有效的手机号码
 * 格式正确返回true,否则false.
 */
function isValidMobile(mobile) {
    //var pattern = /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/;
    var pattern = /^((13[0-9]{1}|15[0-9]{1}|18[0-9]{1}|)+\d{8})$/;   
    return pattern.test(mobile);
}

//省份按钮事件
function changeProvinceHandler() {
	//获取省份下拉框的值
	var province = $("#province").val();
//	alert("province=="+province);
	//如果选择了"请选择这个项" (0表示选择了这个项)
	if (province == 0) {
		//删除市和区域下拉的全部选项
		DWRUtil.removeAllOptions("city");
		DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 		
	//删除市下拉的全部选项
	DWRUtil.removeAllOptions("city");
	//根据所选择的省从后台获取相关的市
	areadwr.findAreaByParendIdAndlvType(province, <%= Area.AreaType.CITY%>, function(data){
	DWRUtil.addOptions("city", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("city", data, "id", "name");   //把data数据填充到城市下拉框
	DWRUtil.removeAllOptions("area");   //清除区域的初始值
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择" }], "id", "name");
	});
	
}

//城市按钮事件
function changeCityHandler() {
	var city = $("#city").val();
	//如果选择了"请选择这个项"
	if (city == 0) {
		//删除区下拉的全部选项
		DWRUtil.removeAllOptions("area");
		DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
		return;
	} 
				
	//删除区域下拉的全部选项
	DWRUtil.removeAllOptions("area");
	//根据所选择的市从后台获取相关的区
	areadwr.findAreaByParendIdAndlvType(city, <%= Area.AreaType.AREA%>, function(data) {
	DWRUtil.addOptions("area", [{"id":0,"name":"请选择..." }], "id", "name");
	DWRUtil.addOptions("area", data, "id", "name"); //把data数据填充到区域下拉框
	});
}

</script>

  </head>
  
<body bgcolor="#F1F1F1" style="margin:0px; text-align:center;">
<div id="top">
 	<!-- 头部-->
 	<%@include file="/manage/mainTop.jsp"%>
</div>
<div id="top2"></div>

<!-- 中间-->
<div id="main1">
<!-- 左边-->
 <%@include file="/manage/mainLeft.jsp"%>
 <div class="mainr2">
<table width="789" height="539" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
  <tr>
    <td width="789" height="39" align="left" valign="middle">
    <span class="STYLE1">用户管理 &gt; 给用户充值</span>    </td>
  </tr>
  <tr>
    <td height="500" align="left" valign="top" >
   <table width="788" height="443" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px solid #DBDBDB;  border-left:1px solid #DBDBDB; " id="a2">
       
        <tr>
        <td width="1" style="border-bottom:1px solid #DBDBDB;"></td>
		 <td width="115" align="center" background="../images/line3.jpg" style="border:1px solid #DBDBDB;">
	       <a href="bsumAction!toShowUserInfo.action">用户查询管理</a></td>
	        
	        <td width="6" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
	        <td width="115" align="center" background="../images/line3.jpg" style="border:1px solid #DBDBDB;">
	        	<a href="bsumAction!toAddUserPage.action" class="STYLE11">添加用户</a>	        </td>
				
				 <td width="9" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
	        <td width="115" align="center" background="../images/line3.jpg" style="border:1px solid #DBDBDB;">
        	    <a href="bsumAction!toDisplayAllUserList.action" class="STYLE11">用户列表</a>	 	        </td>
				
				 <td width="6" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
				 <td width="137" height="22" align="center" bgcolor="#FFFFFF" style="border-top:1px solid #DBDBDB; border-right:1px solid #DBDBDB;" >
        	   		  给用户充值  	        
        	   	</td>
	        <td width="311" align="left" background="../images/line3.jpg" style="border:1px solid #DBDBDB;">&nbsp;</td>
       </tr>
        <tr>
          <td ></td>
          <td height="21" colspan="7" align="center" bgcolor="#FFFFFF" style="border:1px solid #DBDBDB;">&nbsp;</td>
          </tr>
        <tr>
          <td height="399" colspan="8" align="center" valign="top" bgcolor="#FFFFFF" style="border-right:1px solid #DBDBDB;">
        <table  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="172" height="32" align="center" background="images/lm1_bg.jpg">账&nbsp;&nbsp;号</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              
              <td width="161" align="center" background="images/lm1_bg.jpg">姓&nbsp;&nbsp;名</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              
              <td width="211" align="center" background="images/lm1_bg.jpg">用户类型</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              
              <td width="330" height="32" align="center" background="images/lm1_bg.jpg">开始日期</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>

              <td width="330" height="32" align="center" background="images/lm1_bg.jpg">截止日期</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              
              <td width="328" height="32" align="center" background="images/lm1_bg.jpg">最近登录时间</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
                            
              <td width="180" height="32" align="center" background="images/lm1_bg.jpg">账户余额</td>
              <td width="10" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              
              <td nowrap="nowrap" width="200" height="20" align="center" background="images/lm1_bg.jpg">用户操作</td>
            </tr>
            <!-- 显示数据的列表 --> 
 			<s:iterator value="pageObj.data" id="userObj" status="st">
	            <s:if test="#st.odd"><tr bgcolor="#FFFFFF" style='background-color:#F7F7F7';"> </s:if>
                <s:else> <tr ></s:else>
	              <td height="30" align="center">
	              		<s:property value="pageObj.data[#st.index].account"/>	              </td>
	              <td>&nbsp;</td>
	              <td align="left">
	              		&nbsp;<s:property value="pageObj.data[#st.index].userName"/>	              </td>
	              <td>&nbsp;</td>
	              
	              <td align="left">
	              		&nbsp;
	              		<s:if test="pageObj.data[#st.index].type == 0">普通用户</s:if>
	              		<s:else>VIP用户</s:else>	              </td>
	              <td>&nbsp;</td>
	              
	              <td align="left">
	              		&nbsp;<s:date name="pageObj.data[#st.index].beginDate" format="yyyy-MM-dd HH:mm:ss"/>	              </td>
	              <td>&nbsp;</td>
	              
	              <td align="left">
	              		&nbsp;<s:date name="pageObj.data[#st.index].endDate" format="yyyy-MM-dd HH:mm:ss"/>	              </td>
	              <td>&nbsp;</td>
	              
	              <td align="left">
	              		&nbsp;<s:date name="pageObj.data[#st.index].recentlyLoginDate" format="yyyy-MM-dd HH:mm:ss"/>	              </td>
	              <td>&nbsp;</td>
	              
	              <td align="center">
	              		&nbsp;<A href="bsumAction!doShowUserRechargeDetail.action?currentPageNo=${pageObj.pageNo}&userId=${userObj.id}" >
	              			￥<U><s:property value="pageObj.data[#st.index].balance"/></U>
	              		</A>	              
	              </td>
	               <td>&nbsp;</td>
	               
	               <td align="center">
	              		&nbsp;<A href="bsumAction!toEnterUserInfoModPage.action?currentPageNo=${pageObj.pageNo}&userId=${userObj.id}" >
	              			<U>信息修改</U>
	              		</A>	              
	              </td>
	            </tr>
 			</s:iterator>
 			<%-- 展示列表结束 --%>
 			
			<!-- 分页 -->
	<s:if test="pageObj.data != null">
			<s:if test="pageObj.hasOnePage==false">
			<s:form action="bsumAction!toDisplayAllUserList.action" method="get" id="suofrm" name="suofrm">
            <tr>
              <td height="29" colspan="15" align="right" background="images/lm1_bg.jpg" >
              <s:if test="pageObj.pageNo==1">首页</s:if>
			  <s:else>
				  <a href="bsumAction!toDisplayAllUserList.action?pageNo=1" class="STYLE5">首页</a>			  </s:else>&nbsp;
              
              <s:if test="pageObj.hasPrePage==false">上一页</s:if>
			  <s:else> 
				 <a href="bsumAction!toDisplayAllUserList.action?pageNo=<s:property value="pageObj.pageNo-1"/>" class="STYLE5">上一页</a>			  </s:else>&nbsp;

              <s:if test="pageObj.hasNextPage==false">下一页</s:if>
		      <s:else>
				 <a href="bsumAction!toDisplayAllUserList.action?pageNo=<s:property value="pageObj.pageNo+1"/>" class="STYLE5">下一页</a>			  </s:else>&nbsp;
              
              <s:if test="pageObj.pageNo==pageObj.totalPage">末页</s:if>
			  <s:else>
			    <a href="bsumAction!toDisplayAllUserList.action?pageNo=<s:property value="pageObj.totalPage"/>" class="STYLE5"> 末页 </a>			  </s:else>
              
              &nbsp;&nbsp;第${pageObj.pageNo}页&nbsp;|&nbsp;
                                    共<s:property value="pageObj.totalPage"/>页&nbsp;|&nbsp;
                                    共${pageObj.totalRecord}条&nbsp;&nbsp;转至&nbsp;
    			<select onChange="changePage(this.value)" id="pageNo" name="pageNo">
    				<s:iterator value="pageObj.listNum" id="msgid" status="st">
    					<option value="<s:property value="pageObj.listNum[#st.index]"/>"><s:property value="pageObj.listNum[#st.index]"/></option>
    				</s:iterator>
    			</select>&nbsp;&nbsp;    		</td>
            </tr>
            </s:form>
             </s:if>
             <s:else>
				<%--<font class="tip" style="font-size: large;">暂无消费明细!</font>--%>
				<tr>
	              <td height="29" colspan="15" align="right" background="images/lm1_bg.jpg" >
				 	首页&nbsp;上一页&nbsp;下一页&nbsp;末页           
	              	&nbsp;&nbsp;第1页&nbsp;|&nbsp;共1页&nbsp;|&nbsp;&nbsp;	    		  </td>
	            </tr>
		     </s:else>
  		</s:if>
  		<s:else>
	  		<tr>
		        <td height="29" colspan="15" align="right" background="images/lm1_bg.jpg" >
					<p style="color: red;font-size: 12px;text-align: center;">暂无用户信息记录!</p>		    	</td>
		    </tr>	 
  		</s:else>	 
  		<%-- 分页结束 --%>
  			 
            <tr>
              <td height="25" colspan="15" align="right" class="STYLE15">&nbsp;</td>
            </tr>
          </table>          </td>
        </tr>
      </table>
      
      
      
    </td>
  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="8">&nbsp;</td>
  </tr>
</table>	

</div>

</div>
</div>
</body>
</html>
